
#include <stdio.h>

#include "list.h"
#include "image.h"
#include "map.h"
#include "layer.h"

void geopoint_map_init (geopoint_map_t *map)
{
    /* initialize the image buffer
     */
    map->image.width = map->width;
    map->image.height = map->height;
    geopoint_image_init (&map->image);
    
    /* initialize the layers
     */
    geopoint_list_init (&map->layers);
}

void geopoint_map_free (geopoint_map_t *map)
{
    /* free the image buffer
     */
    geopoint_image_free (&map->image);
}

void geopoint_map_add_layer (geopoint_map_t *map, geopoint_layer_t *layer)
{
    geopoint_list_insert (&map->layers, layer);
}

static unsigned int get_color (int red, int green, int blue, int alpha)
{
    unsigned int rgba;
    rgba = ((red & 0xff) << 24 |
            (green & 0xff) << 16 |
            (blue & 0xff) << 8 |
            (alpha & 0xff));
    return rgba;
}

int geopoint_map_save_as_png (geopoint_map_t *map, char *filename)
{
    return geopoint_image_save_as_png (&map->image, filename);
}
